import Vue from 'vue'
import App from './app.vue'

import router from './router'
import store from './store'

import simplebar from 'simplebar-vue';
import 'simplebar-vue/dist/simplebar.min.css';

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';


Vue.use(ElementUI);
Vue.component('simplebar',simplebar)


import VueCron from 'vue-cron'
Vue.use(VueCron);//使用方式：<vueCron></vueCron>


Vue.config.productionTip = false











new Vue({
  router,
  store,
  mounted() {
    window.addEventListener('unload', this.handleUnload)
    window.addEventListener('load', this.handleload)
},methods:{
  handleUnload(){
    // 存储vuex数据到localtorage中
    localStorage.removeItem("hjxxh");
    localStorage.setItem("hjxxh",JSON.stringify(store.getters.state))
  },
  handleload(){
    // 取出localttorage数据存储到vuex
    if(localStorage.getItem("hjxxh")!=null &&localStorage.getItem("hjxxh").length>0){
      
      store.dispatch("setState",JSON.parse(localStorage.getItem("hjxxh")))
      localStorage.removeItem("hjxxh");　　
      if(store.getters.activeTagView!=-1){
        
        router.push(store.getters.activeTagView.name)
      }
      
    }
  }
},
  render: function (h) { return h(App) }
}).$mount('#app')

router.push("home")